package net.cjw.initsb.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {
	public static final String DATE_TIME_FORMAT = "YYYY-MM-dd HH:mm:ss";
	public static final String DATE_FORMAT = "YYYY-MM-dd";
	public static final String DATE_HOUR_FORMAT = "HH:mm:ss";

	public static void main(String[] args) {
		String tmp = format(new Date(), DateUtil.DATE_TIME_FORMAT);
		System.out.println(tmp);
		tmp = format(new Date(), DateUtil.DATE_FORMAT);
		System.out.println(tmp);
		tmp = format(new Date(), DateUtil.DATE_HOUR_FORMAT);
		System.out.println(tmp);
	}

	public static String format(Date date, String format) {
		return new SimpleDateFormat(format).format(date);
	}
}
